#pragma once
#include <OWCommon/GraphicsWindowQt.h>
using namespace OW;
class CViewerWidget : 
	public GLWidget
{
public:
	CViewerWidget(void);
	~CViewerWidget(void);
	static CViewerWidget* getSigleton();
	void clearScene();
	void createScene(float l, float w, float h);
	std::string writeImageBuff(std::string name);

	void setTexture(std::string file);
	void setCoordS(float s);
	void setCoordT(float t);
	inline float getCoordS(){ return m_coord.x(); }
	inline float getCoordT(){ return m_coord.y(); }

	inline bool hasSelectWall(){return m_selectNode!=NULL;}
protected:
	void initImage();
	osg::Node* createPlane(const osg::Vec3d& p1, const osg::Vec3d& p2, const osg::Vec3d& p3, unsigned int row = 10);

	void mousePressEvent( QMouseEvent* event );
	void mouseReleaseEvent( QMouseEvent* event );
	void mouseMoveEvent( QMouseEvent* event );
	void wheelEvent( QWheelEvent* event );

	void updateHouse();

	osg::Node* getInterNodeByScreen(float x, float y, osg::Camera* camera, int traversal);
private:
	osg::Image* m_pImageBuff;
	osg::Group* m_root;
	osg::MatrixTransform* m_house;
	float m_pitch, m_yaw;
	osg::LightSource* m_lightSor;
	osg::Node* m_selectNode;
	osg::Vec2f m_coord;
	int m_buttonMask;
	QPoint m_lastPos;
};

